package com.xinggq.pay.service.controller;

import com.xinggq.pay.service.service.YseCallbackService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author xinggq
 * @Date 2025/9/12
 */
@Tag(name = "银盛支付")
@RestController()
@RequestMapping("/yse/callback")
@Slf4j
@RequiredArgsConstructor
public class YseCallbackController {

  private final YseCallbackService yseCallbackService;

  @Operation(summary = "支付回调")
  @PostMapping("/pay/callback")
  public String payNotify(
          @Parameter(description = "回调通知数据")
          @RequestBody String ysePayNotifyStr) {
    log.info("收到银盛支付异步回调：\n{}", ysePayNotifyStr);
    return yseCallbackService.processYsePayCallback(ysePayNotifyStr);
  }

  @Operation(summary = "退款回调")
  @PostMapping("/refund/callback")
  public String refundNotify(
          @Parameter(description = "回调通知数据")
          @RequestBody String yseRefundNotifyStr) {
    log.info("收到银盛退款异步回调：\n{}", yseRefundNotifyStr);
    return yseCallbackService.processYseRefundCallback(yseRefundNotifyStr);
  }

}
